package mysql

import "gorm.io/gorm"

type Coupon struct {
	gorm.Model
	UserId     int64  `gorm:"type:int;" json:"user_id"`
	CouponName string `gorm:"type:int" json:"coupon_name"`
	EndTime    string `gorm:"type:datetime" json:"end_time"`
}

func (c *Coupon) CreateCoupon(couponName string, endTime string, userId int64) error {
	cou := &Coupon{
		UserId:     userId,
		CouponName: couponName,
		EndTime:    endTime,
	}
	err := DB.Model(&c).Create(&cou).Error
	if err != nil {
		return err
	}
	return nil
}
